# 打开register.html
# 往主页面中输入用户名，密码，电话，邮箱
# 往注册A中输入用户名，密码，电话，邮箱
# 往注册B中输入用户名，密码，电话，邮箱
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
url = 'file:///C:/Users/tedu/Desktop/NSD2406/html/register.html'
driver.get(url)
# 往主页面中输入
driver.find_element(By.CSS_SELECTOR, '#user').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#password').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#tel').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#email').send_keys('123@qq.com')

# 切换到A页面，提供要切换进入的iframe的id/name/element
# driver.switch_to.frame('idframe1')
# driver.switch_to.frame('myframe1')
frame = driver.find_element(By.CSS_SELECTOR, '[src="registerA.html"]')
driver.switch_to.frame(frame)
# 往A页面输入内容
sleep(3)
driver.find_element(By.CSS_SELECTOR, '#userA').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#passwordA').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#telA').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#emailA').send_keys('123@qq.com')

# 先切换回主页面
driver.switch_to.default_content()
# 切换到B页面
driver.switch_to.frame('myframe2')
# 往B页面输入内容
sleep(3)
driver.find_element(By.CSS_SELECTOR, '#userB').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#passwordB').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#telB').send_keys('18812345678')
driver.find_element(By.CSS_SELECTOR, '#emailB').send_keys('123@qq.com')


sleep(3)
driver.quit()